VectorScript provides compound statements as a way to execute several statements as if they were a single statement. This capability is quite useful when it is necessary to combine statements and execute them together—for instance, when being executed as a branch of a control statement or in a loop.
To create a compound statement from a sequence of statements, preface the first statement in the sequence with the BEGIN keyword. The sequence is terminated with the
END keyword, and each statement in the sequence is separated by a semi-colon. For example:
The three statements contained within the BEGIN and
END keywords will be executed together when the compound statement is called.
Compound statements may also be nested; the VectorScript compiler will associate the last BEGIN keyword with the next
END keyword in the script, the second-last
BEGIN with the following
END, and so on. Mismatched
BEGIN-END pairs will cause a VectorScript error to occur.
If you noticed that the body of a script looks suspiciously similar to a compound statement, you would be correct; the script body of any VectorScript script, user-defined procedure, or user-defined function is in fact a single compound statement.